/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */


import java.io.IOException;
import java.io.PrintWriter;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.sql.*;
import java.sql.Connection;
import java.sql.DriverManager;
//import java.util.ArrayList;
//import oracle.jdbc.driver.OracleDriver;

/**
 *
 * @author Jose
 */
public class VOrden extends HttpServlet {

    /**
     * Processes requests for both HTTP <code>GET</code> and <code>POST</code> methods.
     * @param request servlet request
     * @param response servlet response
     * @throws ServletException if a servlet-specific error occurs
     * @throws IOException if an I/O error occurs
     */
    protected void processRequest(HttpServletRequest request, HttpServletResponse response)
    throws ServletException, IOException {
        response.setContentType("text/html;charset=UTF-8");
        PrintWriter out = response.getWriter();
        try {
            /* TODO output your page here
            out.println("<html>");
            out.println("<head>");
            out.println("<title>Servlet Tab_Comp_Cli</title>");
            out.println("</head>");
            out.println("<body>");
            out.println("<h1>Servlet Tab_Comp_Cli at " + request.getContextPath () + "</h1>");
            out.println("</body>");
            out.println("</html>");
            */

        } finally {
            out.close();
        }
    }

    // <editor-fold defaultstate="collapsed" desc="HttpServlet methods. Click on the + sign on the left to edit the code.">
    /**
     * Handles the HTTP <code>GET</code> method.
     * @param request servlet request
     * @param response servlet response
     * @throws ServletException if a servlet-specific error occurs
     * @throws IOException if an I/O error occurs
     */



    protected void doGet(HttpServletRequest request, HttpServletResponse response)
    throws ServletException, IOException {
     response.setContentType("text/html;charset=UTF-8");
        PrintWriter out = response.getWriter();
        try {



        } finally {
            out.close();
        }
    }
    /**
     * Handles the HTTP <code>POST</code> method.
     * @param request servlet request
     * @param response servlet response
     * @throws ServletException if a servlet-specific error occurs
     * @throws IOException if an I/O error occurs
     */
    protected void doPost(HttpServletRequest request, HttpServletResponse response)
    throws ServletException, IOException {
         response.setContentType("text/html");

    // String cod = request.getParameter("cod_cl");
     PrintWriter out = response.getWriter();

 //   String host     = "localhost";
 //    String database = "BDR";

     try
     {

        Class.forName ( "oracle.jdbc.driver.OracleDriver" );

        String url = "jdbc:oracle:thin:@localhost:1521:XE";
        Connection con = DriverManager.getConnection(url,"BDR","12345");

        Statement s = con.createStatement();
        String query = "SELECT * FROM TBM_CLIENTES";
       // String query = "select * from clientes where cod_cliente='" +cod+"'";
        ResultSet rs=s.executeQuery(query);

         Statement s2 = con.createStatement();
        String query2 = "SELECT * FROM TBM_TIPODOCUMENTO";
       // String query = "select * from clientes where cod_cliente='" +cod+"'";
        ResultSet rs2=s2.executeQuery(query2);

         Statement s3 = con.createStatement();
        String query3 = "SELECT * FROM TBM_INVENTARIO_MATERIAPRIMA";
       // String query = "select * from clientes where cod_cliente='" +cod+"'";
        ResultSet rs3=s3.executeQuery(query3);

        Statement s4 = con.createStatement();
        String query4 = "SELECT * FROM TBM_INVENTARIO_MATERIAPRIMA";
       // String query = "select * from clientes where cod_cliente='" +cod+"'";
        ResultSet rs4=s4.executeQuery(query3);

        Statement s5 = con.createStatement();
        String query5 = "SELECT * FROM TBM_INVENTARIO_MATERIAPRIMA";
       // String query = "select * from clientes where cod_cliente='" +cod+"'";
        ResultSet rs5=s5.executeQuery(query3);

        Statement s6 = con.createStatement();
        String query6 = "SELECT * FROM TBM_INVENTARIO_MATERIAPRIMA";
       // String query = "select * from clientes where cod_cliente='" +cod+"'";
        ResultSet rs6=s6.executeQuery(query3);
        //Display the result set in an HTML table
     // out.println("<h2>Se encontro "+cod+"</h2>" +
       //             "<HTML><body background='wallpapers/Hoja-verde.jpg'><font color='white'>" +
        //            "<table><tr><th>los datos son:</th>");

        out.println("<html>"


  + "<head>"
                +"<meta charset='utf-8'>"

		+"<title>BDR-System</title>"

                +"<link rel='stylesheet' type='text/css' href='css/style.css' />"
                +"<link rel='stylesheet' type='text/css' href='css/print.css' media='print' />"
                +"<script type='text/javascript' src='js/jquery-1.3.2.min.js'></script>"
                +"<script type='text/javascript' src='js/example.js'></script>"


		+"<link rel='stylesheet' href='css/style.css' type='text/css' media='screen' />"
		+"<link rel='stylesheet' href='css/social-icons.css' type='text/css' media='screen' />"

		+"<script type='text/javascript' src='js/jquery-1.5.1.min.js'></script>"
		+"<script type='text/javascript' src='js/jquery-ui-1.8.13.custom.min.js'></script>"
		+"<script type='text/javascript' src='js/easing.js'></script>"
		+"<script type='text/javascript' src='js/jquery.scrollTo-1.4.2-min.js'></script>"
		+"<script type='text/javascript' src='js/jquery.cycle.all.js'></script>"
		+"<script type='text/javascript' src='js/custom.js'></script>"


		+"<script src='js/jquery.isotope.min.js'></script>"



		+"<link rel='stylesheet' href='css/nivo-slider.css' type='text/css' media='screen' />"
		+"<script src='js/nivo-slider/jquery.nivo.slider.js' type='text/javascript'></script>"



		+"<link rel='stylesheet' href='css/tabs.css' type='text/css' media='screen' />"
		+"<script type='text/javascript' src='js/tabs.js'></script>"



		+"<script type='text/javascript' src='js/prettyPhoto/js/jquery.prettyPhoto.js'></script>"
		+"<link rel='stylesheet' href='js/prettyPhoto/css/prettyPhoto.css' type='text/css' media='screen' />"



		+"<link rel='stylesheet' media='screen' href='css/superfish.css' />"
		+"<link rel='stylesheet' media='screen' href='css/superfish-left.css' />"
		+"<script type='text/javascript' src='js/superfish-1.4.8/js/hoverIntent.js'></script>"
		+"<script type='text/javascript' src='js/superfish-1.4.8/js/superfish.js'></script>"
		+"<script type='text/javascript' src='js/superfish-1.4.8/js/supersubs.js'></script>"



		+"<link rel='stylesheet' href='js/poshytip-1.0/src/tip-twitter/tip-twitter.css' type='text/css' />"
		+"<link rel='stylesheet' href='js/poshytip-1.0/src/tip-yellowsimple/tip-yellowsimple.css' type='text/css' />"
		+"<script type='text/javascript' src='js/poshytip-1.0/src/jquery.poshytip.min.js'></script>"



		+"<link rel='stylesheet' href='css/jquery.tweet.css' media='all'  type='text/css'/>"
		+"<script src='js/tweet/jquery.tweet.js' type='text/javascript'></script>"



		+"<link rel='stylesheet' href='js/jquery.fancybox-1.3.4/fancybox/jquery.fancybox-1.3.4.css' type='text/css' media='screen' />"
		+"<script type='text/javascript' src='js/jquery.fancybox-1.3.4/fancybox/jquery.fancybox-1.3.4.pack.js'></script>"

               +" </head>"

	+"<body>"


			+"<div id='header'>"

                        +"</div>"




			+"<div id='menu'>"




				+"<div id='menu-holder'>"

					+"<div class='wrapper'>"

						+"<ul id='nav' class='sf-menu'>"
							+"<li class='current-menu-item'><a href='Inicio.jsp'>Inicio<span class='subheader'>o.O</span></a></li>"
							+"<li><a href='Catalogos.html'>Catalogos<span class='subheader'>Gestion de Registros</span></a>"
								+"<ul>"

									+"<li><a href='Catalogo-Clientes.html'><span> Clientes</span></a></li>"
									+"<li><a href='Catalogo-Proveedores.html'><span> Proveedores</span></a></li>"
									+"<li><a href='Catalogo-Inventario.html'><span> Materia Prima</span></a></li>"
								+"</ul>"
							+"</li>"
                                                        +"<li><a href='docTrabajos.html'>Documentos de Trabajo<span class='subheader'>O.o</span></a>"
								+"<ul>"

									+"<li><a href='DT-Cotizacion.html'><span> Crear Cotizacion</span></a></li>"
									+"<li><a href='DT-Orden.html'><span> Crear Orden de Trabajo</span></a></li>"
									+"<li><a href='DT-Resgistros.html'><span> Visualizar Registros</span></a></li>"
								+"</ul>"
							+"</li>"
							+"<li><a href='Facturacion.html'>Facturacion<span class='subheader'></span></a>"
								+"<ul>"
									+"<li><a href='Fact-Generar.html'><span> Crear Factura</span></a></li>"
									+"<li><a href='Fact-Registros.html'><span> Visualizar Registros </span></a></li>"
                                                                         +"<li><a href='Entregas.html'><span> Programar Entregas </span></a></li>"
                                                                +"</ul>"
							+"</li>"
							+"<li><a href='Financiera.html'>Area Financiera<span class='subheader'>Creditos, Compra...</span></a>"
								+"<ul>"
									+"<li><a href='Fi-Creditos.html'><span> Creditos</span></a></li>"
									+"<li><a href='Fi-Gastos.html'><span> Gastos</span></a></li>"
								+"</ul>"
							+"</li>"
							+"<li><a href='Reportes.html'>Reportes<span class='subheader'>Registros, Graficos y Estadisticas</span></a></li>"
                                                +"</ul>"

					+"</div>"


				+"</div>"

			+"</div>"

                        +"<div id='main'>"

				+"<div class='wrapper' >"



					+"<div id='content'>"


					+"<div id='page-title'>"
						+"<span class='title'>Orden de Trabajo</span>"
					+"</div>"



  +"<form id='ingresoOrden' action='SIngresoOrden'>"

					+"<div id='page-content'>"


                                                       +" <div class=one-half'>"


                                                       +"<table id='meta'>"
                                                            +"<tr>"
                                                                +"<td class='meta-head'>No. Orden de Trabajo</td>"
                                                                +"<td><input name='id_orden'  type='text' title='Id_Orden_Trabajo'/></td><!--<td><textarea></textarea></td>-->"
                                                            +"</tr>"
                                                        +"</table>"
                                                        +"</div>"
							+"<div class='one-half last'>"
							 +"<table id='meta'>"
                                                             +"<tr>"
                                                            +"<td class='meta-head'>Fecha</td>"
                                                            +"<td><input name='fecha'  type='text' title='Fecha_Orden' id='date'/></td><!--<td><textarea id='date'></textarea></td>-->"
                                                             +"</tr>"
                                                         +"</table>"

                                                        +"</div>"

                                                        +"<div class='clear'></div>"

						        +"<div id='page-wrap'>"

                                                                +"<div id='identity'>"


                                                                +"<div id='customer'>"

                                                                    +"<div>"

                                                                    +"<table align='center'>"

                                                                        +"<tr>"

                                                                            +"<td> Codigo Cliente</td>"
                                                                            +"<td>");//<input name='id_cli'  type='text' title='Id_Cliente'/></td>"

out.println("<SELECT NAME='id_cli'> ");
         while(rs.next())
        {

            String ID_CLI = rs.getString("CLI_ID");

            out.println(    "<OPTION>"+ ID_CLI +"</OPTION>");//+ nit +"</OPTION>");


        }


                            out.println("</SELECT>");

                            out.println("</td>"

                                                                            +"<td>Codigo Tipo Documento</td>"
                                                                             +"<td>");//<input name='cod_tdoc'  type='text' title='Codigo_Tipo_Documento'/></td>"

out.println("<SELECT NAME='cod_tdoc'> ");
         while(rs2.next())
        {

            String TDOC_ID = rs2.getString("TDOC_ID");

            out.println(    "<OPTION>"+ TDOC_ID +"</OPTION>");//+ nit +"</OPTION>");


        }


                            out.println("</SELECT>");

                            out.println("</td>"
                                                                        +"</tr>"


                                                                    +"</table>"
                                                                    +"<table>"
                                                                        +"<tr>"
                                                                            +"<td>Nombre</td>"
                                                                             +"<td><input name='nom_prod'  type='text' title='Nombre_Producto'/></td>"
                                                                            +"<td>Descripcion</td>"
                                                                             +"<td><input name='desc_prod'  type='text' title='Descripcion'/>"
                                                                       +"<tr>"
//                                                                           +"<td>Cantidad</td>"
//                                                                             +"<td><input name='cant'  type='text' title='Cantidad'/></td>"
                                                                        +"<td>Tiros</td>"
                                                                             +"<td><input name='tiros'  type='text' title='Tiros'/></td>"
                                                                            +"<td>Tamaño Final</td>"
                                                                             +"<td><input name='tam_final'  type='text' title='Tamaño_Final'/></td>"
                                                                       +"</tr>"
                                                                       +"<tr>"
                                                                           +"<td>Tamaño Prensa</td>"
                                                                            +"<td><input name='tam_prensa'  type='text' title='Tamaño_Prensa'/></td>"
                                                                            +"<td>Monto Total</td>"
                                                                             +"<td><input name='monto'  type='text' title='MontoTotal'/></td>"
                                                                        +"</tr>"

//                                                                        +"<tr>"
//                                                                            +"<TD>"
//                                                                                //+"<p><input type='submit' value='Crear Registro' name='cli_btnCR'/></p>"
//                                                                            +"</TD>"
//                                                                        +"</tr>"

                                                                        +"</table>"

                                                        +"</div>"
                                                                 +"<div style='clear:both'></div>"

                                                                    +"</div>"

                                                                    +"<table id='items'>"

                                                                      +"<tr>"
                                                                         +" <td align='center' ><b>Codigo MP</b></td>"
                                                                          +"<td align='center'><b>Cantidad</b></td>"
                                                                          +"<td align='center'><b>Costo Unitario</b></td>"
                                                                          //+"<td align='center'><b>Cantidad</b></td>"
                                                                          //+"<td align='center'><b>SubTotal</b></td>"

                                                                      +"</tr>"

                                                                      +"<tr>"
                                                                      +"<td align='center'>"


                                                       );


out.println("<SELECT NAME='mp'> ");
         while(rs3.next())
        {

            String mp_id = rs3.getString("mp_id");

            out.println(    "<OPTION>"+ mp_id +"</OPTION>");//+ nit +"</OPTION>");


        }


                            out.println("</SELECT>");

out.println(""
         + "</td>"
         +"<td align='center'><input name='cant'  type='text' title='Cantidad'/></td>"
         +"<td align='center'><input name='cost'  type='text' title='Costo Unitario'/></td>"
         +"</tr>"

          +"<tr>"
                                                                      +"<td align='center'>"







                                                               +"</table>"

                                                          +"<h6 class='line-divider'></h6>"

					+"</div>"


					+"</div>"
                                        +"<p><input type='submit' value='Crear Registro' name='cli_btnCR'/></p>"
                                         +"</form>"


				+"</div>"

			+"</div>"


                        +"</div>"


			+"<div id='footer'>"

				+"</div>"


			+"<div id='bottom'>"

				+"<div class='wrapper'>"
					+"<div id='bottom-text'>2013 all rights reserved.</div>"
					+"<div id='to-top' class='poshytip' title='To top'></div>"
				+"</div>"

			+"</div>"


	+"</body>"
+"</html>");




      con.close();
    }
     catch (Exception e)
     {
        out.println(e);
     }
    }

    /**
     * Returns a short description of the servlet.
     * @return a String containing servlet description
     */
    public String getServletInfo() {
        return "Short description";
    }// </editor-fold>

}
